package com.ketai.dao.impl;

import com.ketai.dao.BaseDao;
import com.ketai.dao.CActivityDao;
import com.ketai.pojo.CActivity;

import javax.naming.NamingException;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

/**
 * @Author:石林昭
 * @Description:
 * @Date:Create In 2022-08-04 10:03
 **/
public class CActivityDaoImpl extends BaseDao implements CActivityDao {
    @Override
    public List<CActivity> checkClassify(String cid) throws SQLException, NamingException {
        String sql = "select id,title,position from c_activity where tid="+cid;
        ResultSet rs = null;
        rs = query(sql,null);
       List<CActivity> cActivities = new ArrayList<>();
        while (rs.next()){
            CActivity cActivity = new CActivity();
            cActivity.setId(rs.getString("id"));
            cActivity.setTitle(rs.getString("title"));
            cActivity.setPosition(rs.getString("position"));

            cActivities.add(cActivity);
        }
        return cActivities;
    }

    @Override
    public List<CActivity> AllCheckClf() throws SQLException, NamingException {
        String sql = "select id,title,position from c_activity";
        ResultSet rs = null;
        rs = query(sql,null);

        List<CActivity> cActivities = new ArrayList<>();
        while (rs.next()){
            CActivity cActivity = new CActivity();
            cActivity.setId(rs.getString("id"));
            cActivity.setTitle(rs.getString("title"));
            cActivity.setPosition(rs.getString("position"));
            cActivities.add(cActivity);
        }
        return cActivities;
    }
}
